﻿using GameFramework.Event;
using System;
using TowerDefence_Zombie.Data;
using UnityEngine;
using UnityGameFramework.Runtime;

namespace TowerDefence_Zombie
{
    public class GuideCondition_DoubleAtk : GuideCondition_Base
    {
        public GuideCondition_DoubleAtk(DRGuideCondition conditionInfo, Action conitionCompleteClick)
            : base(conditionInfo, conitionCompleteClick)
        {

        }

        public override void StartCondition()
        {
            base.StartCondition();
            GameEntry.Event.Subscribe(TriggerDoubleAtkEventArgs.EventId, OnTriggerDoubleAtk);
        }

        private void OnTriggerDoubleAtk(object sender, GameEventArgs e)
        {
            TriggerDoubleAtkEventArgs ne = (TriggerDoubleAtkEventArgs)e;
            if (ne == null)
                return;

            IsCompleteFlag = true;
        }

        public override void Dispose()
        {
            GameEntry.Event.Unsubscribe(TriggerDoubleAtkEventArgs.EventId, OnTriggerDoubleAtk);
            base.Dispose();
        }
    }
}
